<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的定时执行</title>
</head>
<body>
        <script>
            var i = 0;
          function foo() {
                i = i +1;
              console.log(i);
              if (i>100){
                  clearInterval(timer);      //取消重复执行
              }

          }
          var timer = setInterval(foo,50)

        </script>

</body>
</html>